import 'package:flutter_eve_plugin/model/health/user_info.dart';
import 'package:flutter_eve_plugin/utils/print_util.dart';

import 'constant.dart';
import 'package:redux/redux.dart';
import 'package:flutter_eve_plugin/store/user/main.dart';
import 'package:flutter_eve_plugin/store/base_action.dart';

AccountInfoState accountInfoReducer(AccountInfoState state, action) {
  if (!(action is BaseAction)) {
    return state;
  }
  BaseAction baseAction = action;
  switch (baseAction.type) {
    case USER_USER_INFO:
      logDebugPrint('httpUserInfo baseaction ${baseAction.data}');
      return state.copyWith(userInfoModel: baseAction.data);
    case YX_LOGIN_DISPATCH:
      AccountInfo info = baseAction.data;
      state.copyWith(userInfoModel: info.userInfo);
      return state.copyWith(accountInfo: baseAction.data);
  }
  return state;
}

// ignore: non_constant_identifier_names
final AccountInfoReducer = combineReducers<AccountInfoState>([accountInfoReducer]);
